package com.quasar.hpatient.view.adapter;

import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.quasar.hpatient.R;
import com.quasar.hpatient.model.custommodel.AllprescriptionDataBean;
import com.vise.log.ViseLog;


/**
 * author : 许建宏
 * Date: 2018/1/16 0016
 * View:
 */

public class AtPrescriptionAdapter extends BaseQuickAdapter<AllprescriptionDataBean, BaseViewHolder> {

    public AtPrescriptionAdapter() {
        super(R.layout.myprescription_item_layout);
    }

    @Override
    protected void convert(BaseViewHolder helper, final AllprescriptionDataBean item) {
        //药品名称
        TextView prescription_items_tv_content = helper.getView(R.id.prescription_items_tv_content);
        StringBuffer stringBuffer = new StringBuffer();
        if (item.getPer_name() != null && item.getPer_name().length() > 0) {
            ViseLog.d("药品名称" + item.getPer_name());
            stringBuffer.append(item.getPer_name());
        }

        if (item.getDoseName() != null && item.getDoseName().length() > 0) {
            stringBuffer.append(item.getDoseName());
        }
        prescription_items_tv_content.setText(stringBuffer.toString());

        //当前药单内容
        TextView tv_title = helper.getView(R.id.tv_title);
        StringBuffer stringBu = new StringBuffer();
        if (item.getPrescriptionDoseDetail() != null && item.getPrescriptionDoseDetail().size() > 0) {
            stringBu.append("每天服用" + item.getPrescriptionDoseDetail().size() + "次\n");
            for (int i = 0; i < item.getPrescriptionDoseDetail().size(); i++) {
                stringBu.append("第" + i + 1 + "次\t" + item.getPrescriptionDoseDetail().get(i).getUseTime().substring(12, item.getPrescriptionDoseDetail().get(i).getUseTime().length() - 3));
                stringBu.append("服用" + item.getPrescriptionDoseDetail().get(i).getUseCount() + "*" + item.getDoseName() + "\n");
            }
        }
        tv_title.setText(stringBu.toString());
        helper.addOnClickListener(R.id.ll_layout);//全部
    }
}
